//
//  WmcMarkedTagView.swift
//  YPWatermarkCamera
//
//  Created by 赵新 on 2022/3/19.
//

import UIKit

class WmcMarkedTagView: WmcBaseTagView {
    lazy var hookEdgeLabel: WmcHookEdgeLabel = {
        let label = WmcHookEdgeLabel()
        return label
    }()

    lazy var underLineView: UIView = {
        let view = UIView()
        view.layer.cornerRadius = 2
        view.layer.masksToBounds = true
        return view
    }()

    lazy var arrowImageView: UIImageView = {
        let imageView = UIImageView(image: "edit_tag_marked_arrow".wmc_image)
        imageView.contentMode = .scaleAspectFit
        return imageView
    }()

    override func makeUI() {
        super.makeUI()
        tagStyle = .marked
        defaultSize = CGSize(width: 255, height: 110)

        contentView.addSubview(arrowImageView)
        arrowImageView.snp.makeConstraints { make in
            make.left.bottom.equalToSuperview()
            make.size.equalTo(CGSize(width: 15, height: 25))
        }

        contentView.addSubview(underLineView)
        underLineView.snp.makeConstraints { make in
            make.bottom.equalTo(arrowImageView.snp.top).offset(4)
            make.left.equalTo(13)
            make.right.equalToSuperview()
            make.height.equalTo(4)
        }

        hookEdgeLabel.text = textLabel.text
        hookEdgeLabel.font = textLabel.font
        hookEdgeLabel.textAlignment = textLabel.textAlignment
        hookEdgeLabel.numberOfLines = textLabel.numberOfLines
        // 狸猫换太子
        textLabel = hookEdgeLabel

        contentView.addSubview(hookEdgeLabel)
        hookEdgeLabel.snp.makeConstraints { make in
            make.top.right.equalToSuperview()
            make.left.equalTo(underLineView.snp.left)
            make.bottom.equalTo(underLineView.snp.top).offset(-4)
        }
    }

    override func changeColor(_ color: WmcBaseTagView.Colors) {
        let uicolor = color.info.hexStr.yp.uiColor
        if color == .white {
            hookEdgeLabel.borderColor = .black
        }else{
            hookEdgeLabel.borderColor = .white
        }
        hookEdgeLabel.textColor = uicolor
        underLineView.backgroundColor = uicolor
        arrowImageView.yp.set(tintColor: uicolor)
    }
}
